﻿@using LanDBom.Models;
@{
    ViewBag.Title = "AuditFlowTesting";
}
@section styles{
    <style>
        .inp{
            width:60px;
            height:30px;
        }
    </style>
}

<div id="塑料" class="jsmb">
    <table>
        <tr>
            <td>
                <select id="sl_ms">
                    <option>原材料种类</option>
                    @foreach (var item in ViewBag.ListPO as List<Projectpr>)
                    {
                       @* if (item.mateial.MA_fne == "塑料")
                        {
                            <option value="@item.PR_name">@item.PR_name</option>
                        }*@
                    }
                </select>
            </td>
            <td>
                <select id="sl_wlfl">
                    <option>物料种类</option>
                    @foreach (var item in ViewBag.ro as List<routing>)
                    {
                        <option value="@item.RO_hang">@item.RO_hang</option>

                    }
                </select>
            </td>
            <td></td>
        </tr>
    </table>
    <table id="SL_WLZC">
    </table>
    <table id="SL_GYSC">
    </table>
    <table id="tab1" style="display:block">
        <thead id="SL_GG">
            <tr>
                <td rowspan="2">规格</td>
                <td>长(mm)</td>
                <td><input type="number" class="inp" id="SL_C" /></td>
                <td>宽(mm)</td>
                <td><input type="number" class="inp" id="SL_K" /></td>
                <td>单层厚度(mm)</td>
                <td><input type="number" class="inp" id="SL_H" /></td>
                <td>密度（g/cm³)</td>
                <td><input type="number" value="0.92" class="inp" id="SL_M" /></td>
                <td>理论净重(KG)</td>
                <td><input type="number" class="inp" id="SL_LLJZ" /></td>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td></td>
                <td>实际净重(KG)</td>
                <td><input type="number" class="inp" id="SL_SJZL" /></td>
                <td>物料克价</td>
                <td id="SL_wldj"></td>
                <td>材料费</td>
                <td id="SL_CLF" class="SL_FY_t SL_JD_YF"></td>
            </tr>
        </tbody>
        <tfoot>
            <tr>
                <td>辅料/运费</td>
                <td><input type="checkbox" class="inp_show" />纸箱</td>
                <td></td>
                <td><input type="checkbox" value="纸管" id="SL_FL_ZG" />纸管</td>
                <td class="SL_FY_t SL_JD_YF" id="SL_ZG"></td>
                <td><input type="checkbox" id="inp_yunf" class="inp_show" value="运费" />运费</td>
                <td class="SL_FY_t" id="SL_sld_yf"></td>
            </tr>
            <tr>
                <td>合计</td>
                <td id="SL_HJ"></td>
            </tr>
        </tfoot>
    </table>
    <table id="tab2" style="display:none">
        <tr>
            <td rowspan="2">规格</td>
            <td>长(mm):</td>
            <td><input type="number" id="SL_gg_C" class="wl_sj" /></td>
            <td>宽(mm):</td>
            <td><input type="number" id="SL_gg_K" class="wl_sj" /></td>
            <td>材料面积(㎡):</td>
            <td id="SL_gg_dx" class="wl_mj"></td>
            <td>平方克重:</td>
            <td><input type="number" id="SL_gg_Z" class="wl_sj" style="width:60px" /></td>
        </tr>
        <tr>
            <td>物料重量(k)</td>
            <td id="SL_wlzl"></td>
            <td>物料克价</td>
            <td id="SL_wldj_2"></td>
            <td>运费</td>
            <td id="SL_qpd_yf"></td>
        </tr>
        <tr>
            <td>合计</td>
            <td id="SL_HJ_2"></td>
        </tr>
    </table>

    <div id="tab3" style="display:none">
        <div>
            <select id="HCC_ZL">
                <option value="0">请选择</option>
                <option value="1">裁切缓冲材</option>
                <option value="2">发泡缓冲材</option>
            </select>
        </div>
        <table id="HC_CQ" style="display:none">
            <thead>
                <tr>
                    <th>长(mm)</th>
                    <th>宽(mm)</th>
                    <th>高(mm)</th>
                    <th>密度()</th>
                    <th>立方价(含税)</th>
                    <th>数量</th>
                    <th>体积(m³)</th>
                    <th>损耗(%)</th>
                    <th>材料价格</th>
                    <th>加工费</th>
                    <th>成本价格</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody id="tab3_tbody">
                <tr>
                    <th><input type="number" class="HC_GG" id="HC_C" style="width:60px;height:30px" /></th>
                    <th><input type="number" class="HC_GG" id="HC_K" style="width:60px;height:30px" /></th>
                    <th><input type="number" class="HC_GG" id="HC_G" style="width:60px;height:30px" /></th>
                    <th>
                        <select id="HC_MD" style="width:60px;height:30px">
                            <option>密度</option>
                            @foreach (var item in ViewBag.par as List<parice>)
                            {
                                if (@item.PA_LengBie == "裁切缓冲材")
                                {
                                    <option value="@item.PA_T">@item.PA_ZhongL</option>
                                }

                            }
                        </select>
                    </th>
                    <th></th>
                    <th><input type="number" class="HC_GG" id="HC_SL" style="width:60px;height:30px" value="1" /></th>
                    <th class="HC_TJ_c"></th>
                    <th><input type="number" class="HC_GG" id="HC_SH" style="width:60px;height:30px" value="10" /></th>
                    <th class="HC_clf"></th>
                    <th class="HC_jgf"></th>
                    <th class="HC_cb"></th>
                    <th><a href="#" id="HC_CZ">添加</a></th>
                </tr>
            </tbody>
            <tfoot>
                <tr>
                    <th>总计</th>
                    <th></th>
                    <th></th>
                    <th></th>
                    <th></th>
                    <th></th>
                    <th id="ALL_TJ"></th>
                    <th></th>
                    <th id="ALL_CL_price"></th>
                    <th id="ALL_JG_price"></th>
                    <th id="ALL_CB_price"></th>
                </tr>
            </tfoot>
        </table>
        <table id="HC_FP" style="display:none">
            <thead>
                <tr>
                    <td>
                        <select id="FP_ZL">
                            <option>请选择类型</option>
                            @foreach (var item in ViewBag.par_hc as List<routing>)
                            {
                                <option value="@item.RO_kon">@item.RO_kon</option>

                            }
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>项目</td>
                    <td>价格（元/g）</td>
                </tr>
            </thead>
            <tbody id="FP_GY_tb">
            </tbody>
            <tfoot>
                <tr>
                    <td>产品重量(g)</td>
                    <td><input type="number" id="FP_WLZL"/></td>
                </tr>
                <tr>
                    <td>产品总计</td>
                    <td id="FP_ZJG"></td>
                </tr>
            </tfoot>
        </table>
    </div>
    
</div>


@section scripts
{
    <script src="~/Scripts/jquery-3.4.1.min.js"></script>
    <script src="~/Scripts/bootstrap.min.js"></script>
    <script>
        //塑料制品
        $(function () {

            //计算理论净重
            function Material_weight() {
                var c = $("#SL_C").val()//长
                var k = $("#SL_K").val()//宽
                var h = $("#SL_H").val()//厚度
                var m = $("#SL_M").val()//密度
                var v = $("#sl_wlfl").val()//物料基数
                if ($("#sl_wlfl").val() == "胶带") {
                    var kg = (c / 1000) * (k / 1000) * h / 1000 * m
                    $("#SL_SJZL").val(kg)
                }
                else {
                    var kg = (c / 1000) * (k / 1000) * h * m * v
                    $("#SL_LLJZ").val(kg)
                }

            }
            //计算物料材料费
            function Calculated_size() {
                var sj = $("#SL_SJZL").val()
                var kj = $("#SL_wldj").text()
                var ee = $("#SL_WLFL").val()
                if (ee == "胶带") {
                    $("#SL_CLF").text((sj * kj * 1000*1.05).toFixed(4))
                }
                else {
                    $("#SL_CLF").text((sj * kj * 1000).toFixed(4))
                }
                SUM_price()
            }
            //根据种类搜索加工费损耗
            function change_sl_ProcessingCost() {
                var sl_ms = $("#sl_ms").val()
                console.log(sl_ms)
                $.ajax({
                    url: "/Procure/Plastic_product",
                    type: 'GET',
                    data: { "state": 1, "miaoshu": sl_ms },
                    success: function (data) {
                        Print_plastic_composition(data)
                        Gram_value()
                        Calculated_size()
                    },
                    error: function () {
                        alert('Request Error');
                    }
                })
            }
            //打印塑料组成
            function Print_plastic_composition(data) {
                $('#SL_WLZC tr').remove();
                $.each(data, function (i, item) {
                    var $tr = $(`
                    <tr style="background-color:#E8ECF6">
                        <td>${item.PA_ZhongL}</td>
                        <td>${item.PR_dai}</td>
                        <td>${item.PA_T}</td>
                        <td class="CL_jg">${item.PA_T * item.PR_dai}</td>
                    </tr>
                `);
                    $('#SL_WLZC').append($tr);
                })
            }
            //计算物料总价
            function SUM_price() {
                var sum=0
                $(".SL_FY_t").each(function (i, item) {
                    sum+=$(item).text()*1
                })
                var num = 0
                $(".SL_FY_v").each(function (j, obj) {
                    num += $(obj).val()*1
                })
                var j_All = 0
                $(".SL_GY_jgf").each(function (x, index) {
                    j_All += $(index).text()*1
                })
                $("#SL_HJ").text(sum * 1 + num * 1 + j_All * 1)
                console.log(sum + "+" + num + "+" + j_All)

            }
            //搜索纸管价格
            function Paper_tube(e) {
                var name = e.val()
                $.ajax({
                    url: "/Procure/Plastic_product",
                    type: 'GET',
                    data: { "state": 3, "miaoshu":  name},
                    success: function (data) {
                        var k = $("#SL_K").val()//宽
                        $.each(data, function (i, item) {
                            $("#SL_ZG").text((item.PA_T * (k / 1000)).toFixed(4))
                        })
                    },
                    error: function () {
                        alert('Request Error');
                    }
                })
            }
            //计算物料克价格
            function Gram_value() {
                var sum = 0
                $(".CL_jg").each(function (i, item) {
                    sum += $(item).text() * 1
                })
                $("#SL_wldj").text(sum / 1000000)
                $("#SL_wldj_2").text(sum / 1000000)
            }
            //计算胶带运费的方法
            function Tape_freight() {
                if ($("#sl_wlfl").val() == "胶带" && $("#inp_yunf").prop("checked")) {
                    var clf = $("#SL_CLF").text()
                    var sum = 0
                    $(".SL_JD_YF").each(function (i, item) {
                        sum += $(item).text() * 1
                    })
                    var yf = sum * 0.05
                    $("#SL_sld_yf").text((yf).toFixed(4))
                }
            }
            //搜索工艺流程
            function Process_flow(e) {
                var name = e.val()
                if (name != "缓冲材") {
                    $.ajax({
                        url: "/Procure/Plastic_product",
                        type: 'GET',
                        data: { "state": 4, "miaoshu": name },
                        success: function (data) {
                            PrintingProcessFlow(data)
                        },
                        error: function () {
                            alert('Request Error');
                        }
                    })
                }
                else {
                    $("#SL_GYSC tr").remove()
                    $('#SL_WLZC tr').remove();
                }
            }
            //打印工艺流程
            function PrintingProcessFlow(data) {
                $("#SL_GYSC tr").remove()
                $.each(data, function (i, item) {
                    var id = item.LB_ID
                    var $tr = $(`
                        <tr>
                            <th>${item.ST_fne}</th>
                            <th>
                                <select id="${item.LB_ID}" class="SL_GYLC">
                                <option value="0">请选择</option>
                                </select>
                            </th>
                            <th>加工费</th>
                            <th class="SL_GY_jgf SL_JD_YF"></th>
                        </tr>
                    `);
                    $("#SL_GYSC").append($tr)
                    $.ajax({
                        url: "/Procure/Plastic_product",
                        type: 'GET',
                        data: { "state": 5, "num": id },
                        success: function (data) {
                            $.each(data, function (i, obj) {
                                $("select[id=" + id + "]").append($(`<option value="${obj.LB_jia}">${obj.LB_fne}</option>`))
                            })

                        },
                        error: function () {
                            alert('Request Error');
                        }
                    })
                })
            }
            //修改净重计算加工费
            function Netweight_Processingfee() {
                var zl = $("#sl_wlfl").val()
                if (zl == "胶带") {
                    var c = $("#SL_C").val()//长
                    var k = $("#SL_K").val()//宽
                    var KG = (c/1000)*(k/1000)
                    $(".SL_GYLC").each(function (i, item) {
                        var jia = $(item).val()
                        $(item).parent().next().next().text((KG * jia).toFixed(4))
                    })
                }
                else if (zl == "气泡袋") {
                    var KG = $("#SL_wlzl").text()
                    $(".SL_GYLC").each(function (i, item) {
                        var jia = $(item).val()
                        $(item).parent().next().next().text(((KG/1000) * jia).toFixed(4))
                    })
                }
                else {
                    var KG = $("#SL_SJZL").val()
                    $(".SL_GYLC").each(function (i, item) {
                        var jia = $(item).val()
                        $(item).parent().next().next().text((KG * jia).toFixed(4))
                    })
                }
            }
            //修改物料克重重新计算运费
            function freight() {
                var zl = $("#sl_wlfl").val()
                var clf = $("#SL_CLF").text()
                var yf = clf * 0.02
                if (zl == "塑料袋") {
                    $("#SL_sld_yf").text((yf).toFixed(4))
                }
            }
            //修改规格算法
            function spec() {
                var zl = $("#sl_wlfl").val()
                if (zl == "胶带") {
                    $("#SL_GG tr").remove()
                    var $tr = $(`<tr>
                                    <td rowspan="2">规格</td>
                                    <td>长(mm)</td>
                                    <td><input type="number" class="inp" id="SL_C" /></td>
                                    <td>宽(mm)</td>
                                    <td><input type="number" class="inp" id="SL_K" /></td>
                                    <td>厚度(um)</td>
                                    <td><input type="number" value="50" class="inp" id="SL_H" /></td>
                                    <td>密度（g/cm³)</td>
                                    <td><input type="number" value="0.91" class="inp" id="SL_M" /></td>
                                </tr>
                                `)
                    $("#SL_GG").append($tr)
                }
                else {
                    $("#SL_GG tr").remove()
                    var $tr = $(`<tr>
                                    <td rowspan="2">规格</td>
                                    <td>长(mm)</td>
                                    <td><input type="number" class="inp" id="SL_C" /></td>
                                    <td>宽(mm)</td>
                                    <td><input type="number" class="inp" id="SL_K" /></td>
                                    <td>单层厚度(mm)</td>
                                    <td><input type="number" class="inp" id="SL_H" /></td>
                                    <td>密度（g/cm³)</td>
                                    <td><input type="number" value="0.92" class="inp" id="SL_M" /></td>
                                    <td>理论净重(KG)</td>
                                    <td><input type="number" class="inp" id="SL_LLJZ" /></td>
                                </tr>
                                `)
                    $("#SL_GG").append($tr)
                }
            }
            //切换显示
            function Switch_display() {
                var zl = $("#sl_wlfl").val()
                if (zl == "气泡袋") {
                    $("#tab1").css({ "display": "none" })
                    $("#tab2").css({ "display": "block" })
                    $("#tab3").css({ "display": "none" })
                }
                else if (zl=="缓冲材") {
                    $("#tab1").css({ "display": "none" })
                    $("#tab2").css({ "display": "none" })
                    $("#tab3").css({ "display": "block" })
                }
                else {
                    $("#tab2").css({ "display": "none" })
                    $("#tab1").css({ "display": "block" })
                    $("#tab3").css({ "display": "none" })
                }
            }
            //添加运费/纸箱价格
            $(document).on("click", ".inp_show", function (e) {
                if ($(e.target).prop("checked")) {
                    if ($(e.target).val() == "运费" && $("#sl_wlfl").val() == "塑料袋") {
                        var clf = $("#SL_CLF").text()
                        var yf = clf * 0.02
                        $(e.target).parent().next().text((yf).toFixed())
                    }
                    else if ($(e.target).val() == "运费" && $("#sl_wlfl").val() == "胶带") {
                        var sum = 0
                        $(".SL_JD_YF").each(function (i, item) {
                            sum += $(item).text() * 1
                        })
                        var yf = sum * 0.05
                        console.log(sum)
                        $("#SL_sld_yf").text((yf).toFixed(4))
                    }
                    else {
                        var $inp = $(`<input type="text" class="SL_FY_v" style="width:60px;height:30px"/>`);
                        $(e.target).parent().next().append($inp)
                    }
                }
                else {
                    if ($(e.target).val() == "运费" && $("#sl_wlfl").val() == "塑料袋") {
                        $(e.target).parent().next().text("")
                    }
                    else if ($(e.target).val() == "运费" && $("#sl_wlfl").val() == "胶带") {
                        $(e.target).parent().next().text("")
                    }
                    else {
                        $(e.target).parent().next().children().remove($inp)
                    }

                }
                SUM_price()
            })
            //切换工艺计算加工费
            $(document).on("change", ".SL_GYLC", function (e) {
                Netweight_Processingfee()
                SUM_price()

            })
            //修改物料种类
            $(document).on("change", "#sl_wlfl", function (e) {
                Process_flow($(e.target))
                Switch_display()
            })
            //添加纸管价格
            $(document).on("click", "#SL_FL_ZG", function (e) {
                if ($(e.target).prop("checked")) {
                    Paper_tube($(e.target))
                }
                else {
                    $("#SL_ZG").text(0)
                    SUM_price()
                }

            })
            //运费/纸箱输入框输入触发
            $(document).on("keyup", ".SL_FY_v", function () {
                SUM_price()

            })
            //修改物料种类
            $(document).on("change", "#sl_wlfl", function () {
                Gram_value()
                Material_weight();
                SUM_price()
                spec()
                Tape_freight()

            })
            //修改物料实际克重
            $(document).on("keyup", "#SL_SJZL", function () {
                Calculated_size()
                Netweight_Processingfee()
                SUM_price()
                freight()
                Tape_freight()
            })
            //点击切换种类
            $(document).on("change", "#sl_ms", function () {
                change_sl_ProcessingCost()
                Tape_freight()
            })
            //修改长宽事件
            $(document).on("keyup", ".inp", function () {
                Netweight_Processingfee()
                Material_weight()
                Tape_freight()
                Calculated_size()
            })
        })
        //气泡袋
        $(function () {
            Calculated_size()
            Calculated_weight_SL()
            //计算物料大小
            function Calculated_size() {
                var c = $("#SL_gg_C").val()
                var k = $("#SL_gg_K").val()
                $("#SL_gg_dx").text((c * k/1000000*2).toFixed(4))
            }
            //计算加工费
            function Netweight_Processingfee() {
                var zl = $("#sl_wlfl").val()
                if (zl == "胶带") {
                    var c = $("#SL_C").val()//长
                    var k = $("#SL_K").val()//宽
                    var KG = (c / 1000) * (k / 1000)
                    $(".SL_GYLC").each(function (i, item) {
                        var jia = $(item).val()
                        $(item).parent().next().next().text((KG * jia).toFixed(4))
                    })
                }
                else if (zl == "气泡袋") {
                    var KG = $("#SL_wlzl").text()
                    $(".SL_GYLC").each(function (i, item) {
                        var jia = $(item).val()
                        $(item).parent().next().next().text(((KG / 1000) * jia).toFixed(4))
                    })
                }
                else {
                    var KG = $("#SL_SJZL").val()
                    $(".SL_GYLC").each(function (i, item) {
                        var jia = $(item).val()
                        $(item).parent().next().next().text((KG * jia).toFixed(4))
                    })
                }
            }
            //计算气泡袋运费
            function freight_qpd() {
                var m = $("#SL_gg_dx").text()
                var yf = (m * 0.1).toFixed(4)
                $("#SL_qpd_yf").text(yf)
            }
            //计算材料重量和价格
            function Calculated_weight_SL() {
                $("#SL_wlzl").text(($("#SL_gg_Z").val() * $("#SL_gg_dx").text()).toFixed(4))

                var jia = ($("#SL_wlzl").text() * $("#SL_gg_dx").text())

            }
            //计算物料价格
            function Sum_up_W_SL() {
                var sum = 0
                var yf = $("#SL_qpd_yf").text()
                var cl = $("#SL_wldj_2").text() * $("#SL_wlzl").text()
                $(".SL_GY_jgf").each(function (i, item) {
                    sum += $(item).text() * 1
                })
                var num = sum * 1 + yf * 1 + cl*1
                $("#SL_HJ_2").text(num)
            }
            //修改克重数量触发
            $(document).on("keyup", "#SL_gg_Z", function (e) {
                Calculated_weight_SL()
                Sum_up_W_SL()
            })
            //修改物料数据触发
            $(document).on("keyup", ".wl_sj", function () {
                freight_qpd()
                Netweight_Processingfee()
                Calculated_size()
                Calculated_weight_SL()
                Sum_up_W_SL()
            })
        })
        //裁切缓冲材
        $(function () {
            //切换密度查找立方价
            $(document).on("change", "#HC_MD", function (e) {
                var jia = $(e.target).val()//立方价格
                $(e.target).parent().next().text(jia)
                ALL_price()
            })
            //改变长/宽/高/数量/损耗时触发
            $(document).on("keyup", ".HC_GG", function (e) {
                Calculated_volume($(e.target))//计算体积
                price($(e.target))//计算费用
                ALL_price()
            })
            //改变密度时触发
            $(document).on("change", "#HC_MD", function (e) {
                price($(e.target))
                ALL_price()
            })
            //点击添加时触发
            $(document).on("click", "#HC_CZ", function (e) {
                Table_row($(e.target))
                ALL_price()
            })
            //添加和删除行的方法
            function Table_row(e) {
                var zt = e.text()
                console.log(zt)
                if (zt == "添加") {
                    e.text("删除")
                    var $tr = $(`
                    <tr>
                        <th><input type="number" class="HC_GG" id="HC_C" style="width:60px;height:30px" /></th>
                        <th><input type="number" class="HC_GG" id="HC_K" style="width:60px;height:30px" /></th>
                        <th><input type="number" class="HC_GG" id="HC_G" style="width:60px;height:30px" /></th>
                        <th>
                            <select id="HC_MD" style="width:60px;height:30px">
                                <option>密度</option>
                                @foreach (var item in ViewBag.par as List<parice>)
                                {
                                    if (@item.PA_LengBie == "裁切缓冲材")
                                    {
                                        <option value="@item.PA_T">@item.PA_ZhongL</option>
                                    }

                                }
                            </select>
                        </th>
                        <th></th>
                        <th><input type="number" class="HC_GG" id="HC_SL" style="width:60px;height:30px" value="1"/></th>
                        <th class="HC_TJ_c"></th>
                        <th><input type="number" class="HC_GG" id="HC_SH" style="width:60px;height:30px" value="10"/></th>
                        <th class="HC_clf"></th>
                        <th class="HC_jgf"></th>
                        <th class="HC_cb"></th>
                        <th><a href="#" id="HC_CZ">添加</a></th>
                    </tr>
                    `)
                    $("#tab3_tbody").append($tr)
                }
                else {
                    e.parent().parent().remove()
                }
            }
            //计算价格的方法
            function price(e) {
                var jia = e.parent().parent().children().eq(4).text()//立方价
                var tj = e.parent().parent().children().eq(6).text()//体积
                var sh = e.parent().parent().children().eq(7).children().val()//损耗

                var clf = jia * tj * (1 + sh * 0.01)//材料费
                var jgf = clf * 0.5//加工费
                var cbkg = clf * 1 + jgf * 1//成本价格
                console.log(jia)
                console.log(tj)
                console.log(sh)
                e.parent().parent().children().eq(8).text((clf).toFixed(4))//材料费
                e.parent().parent().children().eq(9).text((jgf).toFixed(4))//加工费
                e.parent().parent().children().eq(10).text((cbkg).toFixed(4))//成本价格
            }
            //计算体积的方法
            function Calculated_volume(e) {
                var c = e.parent().parent().children().eq(0).children().val()//长
                var k = e.parent().parent().children().eq(1).children().val()//宽
                var g = e.parent().parent().children().eq(2).children().val()//高
                var s = e.parent().parent().children().eq(5).children().val()//数量
                var tj = c * k * g / 1000000000 * s
                e.parent().parent().children().eq(6).text((tj).toFixed(4))
            }
            //计算总价的方法
            function ALL_price() {
                var clf = 0
                var jhf = 0
                var cb = 0
                var tj=0
                $(".HC_clf").each(function (i, item) {
                    clf += $(item).text()*1
                })
                $("#ALL_CL_price").text((clf).toFixed(5))

                $(".HC_TJ_c").each(function (i, obj) {
                    tj += $(obj).text() * 1
                })
                $("#ALL_TJ").text((tj).toFixed(5))

                $(".HC_jgf").each(function (i, sum) {
                    jhf += $(sum).text() * 1
                })
                $("#ALL_JG_price").text((jhf).toFixed(5))

                $(".HC_cb").each(function (i, index) {
                    cb += $(index).text() * 1
                })
                $("#ALL_CB_price").text((cb).toFixed(5))

            }
        })
        //发泡缓冲材
        $(function () {
            //切换裁切和发泡
            $(document).on("change", "#HCC_ZL", function (e) {
                var zl = $(e.target).val()
                if (zl == 1) {
                    $("#HC_FP").css({ "display": "none" })
                    $("#HC_CQ").css({ "display": "block" })
                }
                else if (zl == 2) {
                    $("#HC_FP").css({ "display": "block" })
                    $("#HC_CQ").css({"display":"none"})
                }
                else {
                    $("#HC_FP").css({ "display": "none" })
                    $("#HC_CQ").css({ "display": "none" })
                }
            })
            //切换物料类型
            $(document).on("change", "#FP_ZL", function (e) {
                Process_flow($(e.target))
                Calculate_the_price()
            })
            //输入物料重量时触发
            $(document).on("keyup", "#FP_WLZL", function () {
                Calculate_the_price()
            })
            //搜索发泡缓冲料工艺流程
            function Process_flow(e) {
                var zl = e.val()
                $.ajax({
                    url: "/Procure/Plastic_product",
                    type: 'GET',
                    data: { "state": 6, "miaoshu": zl },
                    success: function (data) {
                        Printing_process_flow(data)
                    },
                    error: function () {
                        alert('Request Error');
                    }
                })
            }
            //打印工艺流程
            function Printing_process_flow(data) {
                $("#FP_GY_tb tr").remove()
                $.each(data, function (i, item) {
                    var id = item.LB_ID
                    var $tr = $(`
                    <tr>
                        <td>${item.RO_yao}</td>
                        <td class="FP_GYJG">${item.RO_bei}</td>
                    </tr>
                    `);
                    $("#FP_GY_tb").append($tr)
                    
                })
            }
            //计算总价格
            function Calculate_the_price() {
                var sum = 0
                var z = $("#FP_WLZL").val()
                $(".FP_GYJG").each(function (i, item) {
                    
                    sum += $(item).text()*1
                })
                var jia = z * sum
                $("#FP_ZJG").text((jia).toFixed(5))
            }
        })
    </script>
}